window.onload = function() {
    //事件的捕获和冒泡
    let child = document.getElementById("div_child")
    let parent = document.getElementById("div_parent")

    child.addEventListener("click", () => {
        event.stopPropagation() //阻止冒泡
        console.log("child被点击了")
    })
    parent.addEventListener("click", () => {
        console.log("parent被点击了")
    })

    // document.querySelectorAll("ul li")[0].addEventListener("click", () => {
    //     console.log(event.target.innerText)
    // })
    // document.querySelectorAll("ul li")[1].addEventListener("click", () => {
    //     console.log(event.target.innerText)
    // })
    // document.querySelectorAll("ul li")[2].addEventListener("click", () => {
    //         console.log(event.target.innerText)
    //     })

    // document.getElementsByClassName("sty")[0].addEventListener("click", () => {
    //     console.log(event.target.innerHTML)
    //     console.log((event.currentTarget))
    // })
    document.querySelectorAll("ul")[0].addEventListener("click", () => {
        console.log(event.target.innerHTML)
        console.log((event.currentTarget))
    })

    document.getElementsByTagName("a")[0].addEventListener("click", () => {
        event.preventDefault() //阻止超链接跳转
        console.log("111")
    })

    //windows--->document--->html--->body--->div--->div\ul\form
    console.log(document.documentElement)
    console.log(document.body)
    document.body.append("11111")
    window.alert("111")
}